﻿ /**
* Инфо класс для секции
* @author Firsoff Maxim, icq:234859730, firsoff_maxim@mail.ru, tel:+79222345364
* @version 0.1/12.04.2008 21:36
*/

package ru.vega_int.firsoff.as3.cms 
{
	public class SectionInfo 
	{
		//	PROPERTIES
		//	public
		
		//	private
		protected var _images:Array;			//	изображения этой секции
		protected var _thumbnails:Array;		//	тумбаляшки
		protected var _captions:Array;			//	надписи для фоток секции
		protected var _imageWidths:Array;
		protected var _imageHeights:Array;
		protected var _thmbWidths:Array;
		protected var _thmbHeights:Array;
		protected var _outline:Array;
		
		protected var _description:String;	//	надпись для секции
		protected var _name:String;				//	имя секции
		protected var _type:String;
		private var _fileNames:Array;
		
		private var _path:String;
		
		//	const
		public static const PORTFOLIO:String = 'portfolio';		//	тип портфолио
		public static const CONTACTS:String = 'contacts';		//	тип контакты
		public static const INFO:String = 'info';				//	тип инфо
		public static const CLIENTS:String = 'clients';			//	тип клиенты
		public static const WWW:String = 'www';			//	тип клиенты
		//	----------------------------------------------------------------------------------
		
		//	CONSTRUCTOR
		public function SectionInfo(data:XML=null, path:String=null) 
		{
			_path = path;
			if (data) 
			{ 
				init(data);
			};
		};
		
		//	METHODS
		//	private
		private function init(data:XML):void
		{
			this._name = data.@name;
			this._type = data.@type;
			_captions = new Array();
			_images = new Array();
			_description = data.@description;
			_thumbnails = new Array();
			_imageWidths = new Array();
			_imageHeights = new Array();
			
			_thmbHeights = new Array();
			_thmbWidths = new Array();
			_outline = new Array();
			_fileNames = new Array();
			for each(var image:XML in data.elements())
			{
				var caption:String = (image.@caption == 'image caption') ? '' : image.@caption;
				var imageFile:String = path + '/images/' + image.@name;
				var thumbFile:String = path + '/thumbnails/' + image.@name;
				_images.push(imageFile);
				_thumbnails.push(thumbFile);
				_fileNames.push(image.@name);
				_captions.push(caption);
				_imageWidths.push(Number(image.@imagewidth));
				_imageHeights.push(Number(image.@imageheight));
				
				_thmbWidths.push(Number(image.@thmbwidth));
				_thmbHeights.push(Number(image.@thmbheight));
				
				_outline.push(image.@outlines);
			};
			
		};
		//	public
		
		//	----------------------------------------------------------------------------------
		
		//	GETTERS/SETTERS
		public function get images():Array { return _images; };
		
		public function get thumbnails():Array { return _thumbnails; };
		
		public function get captions():Array { return _captions; };
		
		public function get name():String { return _name; };
		
		/**
		 * Папка секции
		 */
		public function get path():String { return (_path + this.name); };
		
		/**
		 * Тип секции
		 */
		public function get type():String { return _type; };
		public function set type(value:String):void 
		{
			_type = value;
		};
		/**
		 * Надпись для секции
		 */
		public function get description():String { return _description; };
		
		public function set name(value:String):void 
		{
			_name = value;
		};
		
		public function get imageWidths():Array { return _imageWidths; };
		
		public function get outline():Array { return _outline; };
		
		
		public function get fileNames():Array { return _fileNames; };
		
		public function get imageHeights():Array { return _imageHeights; };
		
		public function get thmbWidths():Array { return _thmbWidths; };
		
		public function get thmbHeights():Array { return _thmbHeights; };
		
		public function set description(value:String):void 
		{
			_description = value;
		};
		
		
		//	----------------------------------------------------------------------------------
		
		//	HANDLERS
		
		//	----------------------------------------------------------------------------------
	};
	
};
